package com.grt192.demos;

import com.grt192.core.GRTObject;
import com.grt192.event.SensorChangeListener;
import com.grt192.event.SensorEvent;
import com.grt192.spot.sensor.GRTCompass;

public class CompassDemo extends GRTObject implements SensorChangeListener {

    public CompassDemo() {
        //change threshold 0, poll per 20 ms.
        GRTCompass c = new GRTCompass(0, 20, "compass");
        c.addSensorChangeListener(this);
        c.start();
        setPrinting(true);
    }

    public void sensorStateChanged(SensorEvent e, String key) {
        //selective printing: only for angle
        if (key.equals(GRTCompass.ANGLE)) {
            log(GRTCompass.ANGLE  + ":"+ e.getData(GRTCompass.ANGLE));
        }
    }
}
